import Vue from 'vue'
import auth from '../auth'
import axios from 'axios'
import consts from '../consts'
import qs from 'qs'

export default {
  install(Vue) {
    Vue.prototype.$auth = auth
    Vue.prototype.$http = axios,
      Vue.prototype.$consts = consts
    Vue.prototype.$qs = qs
  }
}



Vue.filter('handleTime', function (value) {
    if (value) {
      return value.slice(5, 10)
    }
  }),

  Vue.filter('toFixed', num => {
    if (num) {
      return Number(num).toFixed(2)
    }
  })

Vue.filter("twoFloat", number => {
  if (!number) return number
  var number1 = number.toString().split('.')
  if (number1.length == 1) {
    number = number.toString() + '.00'
    return number
  }
  if (number1.length > 1) {
    if (number1[1].length < 2) {
      number = number.toString() + '0'
    }
    if (number1[1].length > 2) {
      number = number1[0] + '.' + number1[1].substring(2, 0)
    }
    return number
  }
})

Vue.filter('fetchDay', time => {
  if (time) {
    return time.substring(time.length - 2).replace(/\b(0+)/gi, "")
  }
})